package com.chuangke.lowcode.component.flow;

import com.chuangke.metadata.entity.SysBill;
import com.chuangke.metadata.service.SysBillService;
import com.chuangke.lowcode.LowCodeContext;
import com.chuangke.lowcode.component.ProgressComponent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 根据formId加载flowId
 */
@Component
public class FlowIdQueryComponent implements ProgressComponent {

    @Autowired
    SysBillService sysBillService;

    public void process(LowCodeContext modelContext) {
        if (modelContext.getFormId() == null) {
            return ;
        }
        SysBill sysBill = sysBillService.findById(modelContext.getFormId()) ;
        if (sysBill == null) {
            return ;
        }
        modelContext.setFlowId(sysBill.getFlowId()) ;
    }
}
